#include "SocketMgr.h"


SocketMgr::SocketMgr(void)
{
}


SocketMgr::~SocketMgr(void)
{
}

bool SocketMgr::initSocket( std::string ip, short adport )
{
	ClientSocket::InitSocket();
	_clientSocket.registerCallBack(this, &SocketMgr::recvMsg);
	return _clientSocket.connection(ip, adport);
}

void SocketMgr::recvMsg( void* data )
{
	TagNSMsg* msg  =  (TagNSMsg*)data;

	auto it = _keyList.find(msg->cmd);
	if(it != _keyList.end())
	{
		string key = it->second;
		_eventContainer.snedEvent(key, data);
	}

}

void SocketMgr::sendMsg( TagNCMsg* data )
{
	int i  = _clientSocket.sendMsg(data, data->size);
}
